package com.lsp.microarticle.article.openfeign;

import com.lsp.microcommon.common.CommonResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 服务调用失败
 */
@Component
public class ArticleFeignServiceFallback implements FallbackFactory<ArticleFeignService> {


    @Override
    public ArticleFeignService create(Throwable cause) {

        return () -> {
//                将捕获到的异常写入错误日志
            System.out.println(cause.getMessage());
            return CommonResult.error("发布文章获得积分失败");
        };
    }
}
